package com.ssm.reader.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ssm.reader.entity.Category;
import com.ssm.reader.mapper.CategoryMapper;
import com.ssm.reader.service.CategoryService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/*
 *CategoryService实现类
 *
 *@data 2022-04-29
 */

@Service("categoryService")
@Transactional(propagation = Propagation.NOT_SUPPORTED,readOnly = true)
//默认都不使用事务，只能读
public class CategoryServiceImpl implements CategoryService {
    @Resource
    private CategoryMapper categoryMapper;

    //查询所有图书类别
    /*
    * 查询,不需要开启事务
    *
    * */

    public List<Category> selectAll() {
        List<Category> categories = categoryMapper.selectList(new QueryWrapper<Category>());
        return categories;
    }
}
